class AdminUser < ApplicationRecord
  has_secure_password

  validates :password, length: { in: 6..20 }
  validates :name, uniqueness: true

  def token
    {
      token: JWT.encode({user_id: self.id}, Rails.application.secrets.secret_key_base)
    }
  end

  def to_json
    # self.slice(:username, :email)
  end
end
